<?php


// +----------------------------------------------------------------------
// | LuluUI [ Lulu COMPANY WEB SHOW]
// +----------------------------------------------------------------------
// | Copyright (c) 2010 http://www.luluui.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: uuleaf <uuleaf@163.com>
// +----------------------------------------------------------------------
class News_cateModel extends IcateModel {
	public $fields_set = array (
		'cate_id' => array (
			't' => 'input',
			'v' => 0
		),
		'parent_id' => array (
			't' => 'input',
			'v' => 0
		),
		'name' => array (
			't' => 'input',
			'v' => 0
		),
		'enname' => array (
			't' => 'input',
			'v' => 0
		),
		'title' => array (
			't' => 'input',
			'v' => 0
		),
		'keyword' => array (
			't' => 'input',
			'v' => 0
		),
		'detail' => array (
			't' => 'text',
			'v' => ''
		),
		'thumb' => array (
			't' => 'input',
			'v' => ''
		),
		'adv1' => array (
			't' => 'input',
			'v' => ''
		),
		'adv2' => array (
			't' => 'input',
			'v' => ''
		),
		'oid' => array (
			't' => 'input',
			'v' => 0
		)
	);
	public function doPost($par) {
		$data = array ();
		$data['parent_id'] = empty ($par['parent_id']) ? 0 : $par['parent_id'];
		$data['name'] = empty ($par['name']) ? '' : $par['name'];
		$data['oid'] = empty ($par['oid']) ? 0 : $par['oid'];
		$data['detail'] = empty ($par['detail']) ? '' : $par['detail'];
		$data['thumb'] = empty ($par['thumb']) ? '' : $par['thumb'];
		$data['adv1'] = empty ($par['adv1']) ? '' : $par['adv1'];
		$data['adv2'] = empty ($par['adv2']) ? '' : $par['adv2'];
		if (empty ($data['name'])) {
			$this->error = '分类名称不能为空';
			return false;
		}
		if (!$this->create($data)) {
			return false;
		}
		$newkey = $this->add($data);
		if (!$newkey) {
			return false;
		}
		$map['cate_id'] = $newkey;

		$this->getTree(1);
		return $data;
	}
}
?>